1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- "use client";
- import { AdItem } from "@/api/customservice";
- import { useRouter } from "@/i18n/routing";
- import React from "react";
- import { Pagination } from "swiper/modules";
- import { Swiper, SwiperSlide } from "swiper/react";
- interface AdboxProps {
- data: AdItem[];
- }
- const Adbox: React.FC<AdboxProps> = ({ data }) => {
- const router = useRouter();
- const doClick = async (data: AdItem) => {
- switch (data.action_type) {
- case 2:
- window.open(data.action_params, "_blank");
- break;
- case 3:
- let path = data.action_params;
- if (path) router.push(path);
- break;
- case 5:
- data?.action_params ? await eval(data?.action_params || "") : "";
- break;
- default:
- break;
- }
- };
- return (
- <div className="p-[.1rem]">
- <Swiper
- spaceBetween={10}
- autoplay
- modules={[Pagination]}
- pagination={{ clickable: true }}
- >
- {!!data?.length &&
- data.map((item) => {
- return (
- <SwiperSlide key={item.id} onClick={() => doClick(item)}>
- <img src={item.content} alt="" />
- </SwiperSlide>
- );
- })}
- </Swiper>
- </div>
- );
- };
- export default Adbox;
|